package com.ds.infrastructure.hyperspace.console.model.request.deploy.deploydata;

import com.ds.infrastructure.hyperspace.console.dto.deploydata.VipMapDTO;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author: yaozhendong
 * @create: 2019-10-21 10:48
 **/
@Data
@NoArgsConstructor
public class VipMapForm {
    @NotBlank
    private String vipId;
    @NotNull
    private Integer vipPort;
    @NotBlank
    private String hostGroupId;
    @NotNull
    private Integer hostGroupPort;

    public static VipMapDTO toDTO(VipMapForm item) {
        VipMapDTO vipMapDTO = new VipMapDTO();
        vipMapDTO.setVipId(item.getVipId());
        vipMapDTO.setVipPort(item.getVipPort());
        vipMapDTO.setHostGroupId(item.getHostGroupId());
        vipMapDTO.setHostGroupPort(item.getHostGroupPort());
        return vipMapDTO;
    }

    public static VipMapForm toVO(VipMapDTO dto) {
        VipMapForm vipMapForm = new VipMapForm();
        vipMapForm.setVipId(dto.getVipId());
        vipMapForm.setVipPort(dto.getVipPort());
        vipMapForm.setHostGroupId(dto.getHostGroupId());
        vipMapForm.setHostGroupPort(dto.getHostGroupPort());
        return vipMapForm;
    }
}
